home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
dskut
/
p22v12.zip
/
PATCH22.DOC
< prev
next >
Wrap
Text File
|
1991-08-08
|
15KB
|
371 lines
PATCH22
version 1.2 (8 August 1991)
Jurgen A. Doornik
1. Introduction.
___________________________________________________________________
PATCH22 can be used to make patches to any file. The main
advantage is that it gives a format to distribute patches. You
can avoid detailed description of DEBUG commands. Instead you
just supply PATCH22 with the patch in a *.P22 file.
PATCH22 can also accept patches on the command line.
Patches have a C-like character constant format, making
it easy to enter hexadecimal values. PATCH22 will show the
context of the patch, but can work silently as well.
PATCH22 is written in C (source code provided), and faster than
many other public domain patch programs.
PATCH22 is written by Jurgen Doornik.
The disk (or archive) should contain the following files:
PATCH22.C - source code (MSC 6.0)
PATCH22.DOC - this documentation
PATCH22.EXE - executable file.
*.P22 - patch files (if any).
If you have any suggestions for improvement, or find any bugs,
please report them to me, via email:
BITNET/EARN: ECONZ@UK.AC.OX.VAX
or by mail:
Jurgen Doornik
Institute of Economics and Statistics
St Cross Building, Manor Road
Oxford OX1 3UL
United Kingdom
Special thanks are due to Arjen Merckens, who spotted many bugs and
gave useful suggestions. Needless to say that all remaining errors
are mine.
Arjen is author of BOOTCOMP.zip: a package which uses the original
BIOS interrupts to detect ANY changes to the bootsector [possibly]
made by a virus. He also wrote ACD (ChDir FAST; more features than
LCD/NCD and free).
2. How to execute PATCH22.
___________________________________________________________________
PATCH22 can accept patches on the command line or from a file.
2.1 Command line patch.
_______________________
form: PATCH22 fname patch
fname - file to be patched
patch - patch command: +##*##si?search_text?new_text?
If the patch line on the command line contains spaces, it must be
enclosed in double quotes.
examples:
PATCH22 test.exe ?abc?cde? replace (with confirmation)
every occurrence of abc with cde.
PATCH22 test.exe "?a c?c e?" replace (with confirmation)
every occurrence of a c with c e.
If in the last example the double quotes are omitted, PATCH22 will
think that the patch is ?a, and tell you that it expects a ?.
2.2 Command file patch.
_______________________
form: PATCH22 @fname
@fname - file with (multiple) PATCH22 commands, with format:
fname +##*##si?Search_text?New_text?
If the patch command is in a file, line breaks in the Search_text
and New_text are ignored.
example:
PATCH22 @test.p22
where test.p22 looks like:
; comment lines start with a semi colon.
test.exe ?a c?c e?
; line breaks in the Search_text and New_text are ignored:
test.exe ?a cdd?c edd?
; equals
test.exe ?a cd
d?c ed
d?
; note that no double quotes are used here.
3. The patch command.
___________________________________________________________________
form: +##*##si?Search_text?New_text?"
syntax: patch = Conditions "?" Search_text "?" New_text "?".
The syntax reads as follows:
"a" indicates a literal text a.
[b] indicates an optional item b.
{c} indicates one or more occurences of c.
d|e indicates either d or e.
3.1 The Conditions.
syntax: Conditions = [Offset][Max_#_patches][Silent_mode].
Offset = ["+"] long | "-" long.
Max_#_patches= "*" int.
long = ["0"] ["x" | "X"] digit {digit}.
int = ["0"] ["x" | "X"] digit {digit}.
Silent_mode = "s".
Ignore_case = "i".
The Offset is a signed long integer, while the maximum number of patches
is a * followed by an unsigned integer. These integers can be decimal,
hexadecimal (leading 0x or 0X) or octal (leading 0).
An s indicates silent mode. Each number is read up to the first character
which is not part of it.
An i indicates case insensitive searching. The search string is converted
to uppercase, so comparosion is mad in uppercase. The default is case
sensitivity.
The Conditions field can be empty, in which case the Offset is zero,
every patch has to be confirmed, and there is no maximum number of
patches.
examples: 0x131d Offset is 131d (hexadecimal), no maximum
number of patches.
+0177*12 Offset is 177 (octal), not more than 12 patches.
+177*12 Offset is 177 (decimal), not more than 12 patches.
*1s Zero Offset, one patch, silent mode (no prompt for
confirmation of patch).
*09?n?n? The 0 in the Max_#_patches field indicates an octal
number, but 9 is not octal, so scanning stops and
a 0 is read. The 9 then is interpreted as the
Offset. However a request of 0 patches generates
an error message.
3.2 The Search_text and New_text.
_________________________________
syntax: Search_text = [ {chars | escape_code} ].
escape_code = "\a" | "\b" | "\f" | "\n" | "\r" | "\t" | "\v"
| "\\" | "\?" | "\'" | "\""
| "\" octal [octal [octal]]
| "\x" hex [hex]
| "\w" hex [hex [hex [hex]]]
| "\h" hex hex {hex hex}.
New_text = Search_text.
The text is a C-type character constant. It may contain the C
escape codes
\a (07h), \b (08h), \f (0Ch), \n (0Ah), \r (0Dh), \t (09h), \v (0Bh);
or
\### (octal byte, not more than 3 digits);
\x## (hexadecimal byte, not more than 2 digits).
\w#### (hexadecimal word, not more than 4 digits).
The characters \ ? ' " must be written as: \" \\ \? \' \".
An additional escape code is \h, which indicates that the rest of the
text (up to the question mark which indicates the end) consists
of two-digit hexadecimal numbers.
examples: \h0d0a00 three hexadecimal numbers:
carriage return, line feed, null character.
\r\n\0 the same three characters, in escape codes,
(note that \0 is an octal number).
«gr_» literal text.
\x1\xa\wb000 two bytes and one word: 01h 0Ah B000h
(since on IBM PC's low order byte comes before
hi order byte this is written as 01h 0Ah 00h B0h)
3.3 How the patch is executed.
______________________________
Assume non-silent mode (default).
First PATCH22 locates the search string. If the search string is
empty, the first byte in the file matches. Then PATCH22 displays
the search string.
Next it moves the file pointer Offset bytes from the start of the
found search string. (If the Offset is negative, PATCH22 will move
backwards.)
Then it will display the context with the bytes selected for modi-
fication highlighted. PATCH22 will also display the new text, and
prompt for confirmation of the patch.
The file will be unchanged in size, unless the patch extends beyond
the current end of the file. The time and date stamp of the file are
updated.
Example 1: replace a tex